{extend name="layout"}
{block name="style"}{/block}
{block name="left_main"}
  <ul class="layui-nav layui-nav-tree" style="width:100%;">
    <li class="layui-nav-item {if in_array($controller,['news'])}layui-this{/if}"><a href="{:url('news/index')}">新闻管理</a></li>
    <li class="layui-nav-item {if in_array($controller,['ask'])}layui-this{/if}"><a href="{:url('ask/index')}">咨询管理</a></li>
    <li class="layui-nav-item {if in_array($controller,['cases'])}layui-this{/if}"><a href="{:url('cases/index')}">案例管理</a></li>
    <li class="layui-nav-item {if in_array($controller,['service'])}layui-this{/if}"><a href="{:url('service/index')}">项目管理</a></li>
    <li class="layui-nav-item {if in_array($controller,['team'])}layui-this{/if}"><a href="{:url('team/index')}">团队管理</a></li>
  </ul>
{/block}
{block name="right_main"}
<div class="layui-tab layui-tab-brief" style="margin:0;box-shadow:none;border:0;">
  <ul class="layui-tab-title">
    <li {:request()->action()=='index'?'class="layui-this"':''} onclick="location.href='{:url('news/index')}'">文章列表</li>
    <li {:request()->action()=='category'?'class="layui-this"':''} onclick="location.href='{:url('news/category')}'">文章分类</li>
  </ul>
<!--  {$searchForm?:''}-->
      <!--    搜索-->
    <div class="layui-tab-content" style="padding:20px;background:#fff;">
        <fieldset class="layui-elem-field">
            <legend>查找</legend>
            <div class="layui-field-box">
                <form class="layui-form" action="">
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">新闻标题</label>
                            <div class="layui-input-inline">
                                <select name="id"  lay-filter="" lay-search="true">
                                    <option value="" >请搜索新闻标题</option>
                                    {volist name="news" id="vo"}
                                    <option value="{$vo.id}" {:input('id')==$vo.id?'selected':''}>{$vo.title}</option>
                                    {/volist}

                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline">
                                <select name="status" lay-filter="">
                                    <option value="">全部</option>
                                    <option value="1" {:input('status')=='1'?'selected':''}>可用</option>
                                    <option value="0" {:input('status')=='0'?'selected':''}>禁用</option>
                                </select>
                            </div>
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">创建时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="min_create_time" value="{:input('min_create_time')?:''}" id="min_create_time" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" name="max_create_time" value="{:input('max_create_time')?:''}" id="max_create_time" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <script>
                            layui.use(['laydate'], function() {
                            var laydate = layui.laydate;
                            laydate.render({
                            elem: '#min_create_time'
                            });
                            laydate.render({
                            elem: '#max_create_time'
                            });
                            });
                        </script>
                    </div>




                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-inline">
                            <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="search">查找</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
    </div>
      
      
  <div class="layui-tab-content" style="padding:20px;">
    {$batheDeleteButton?:''}
    {$addButton?:""}
    <table class="layui-table" lay-data="{skin: 'line',method:'post', url:'{:url('news/index',input('get.'))}', page:true, id:'table'}" lay-filter="table">
      <thead>
        <tr>
          <th lay-data="{checkbox:true}"></th>
          <th lay-data="{field:'id', width:80, sort: true}">ID</th>
          <th lay-data="{field:'lang', width:80}">语言</th>
          <th lay-data="{field:'cid', width:100, sort: true}">分类</th>
          <th lay-data="{field:'title', width:200}">标题</th>
          <th lay-data="{field:'create_time', width:200}">创建时间</th>
          <th lay-data="{field:'status', width:120, sort: true, templet:'#status'}">发布状态</th>
          <th lay-data="{width:126,fixed:'right', align:'center', toolbar: '#bar'}">操作</th>
        </tr>
      </thead>
    </table>
    <script type="text/html" id="is_pass">
      {{# if(d.is_delete===1){}}
      <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="is_delete">已删除</a>
      {{# }else{}}
      <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="is_delete">未删除</a>
      {{# }}}
    </script>
    <script type="text/html" id="is_pass">
      {{# if(d.is_pass===1){}}
      <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="is_pass">通过</a>
      {{# }else{}}
      <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="is_pass">未通过</a>
      {{# }}}
    </script>
    <script type="text/html" id="status">
      {{# if(d.status===1){}}
      <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="status">已发布</a>
      {{# }else{}}
      <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="status">未发布</a>
      {{# }}}
    </script>
    <script type="text/html" id="bar">
      <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="edit">编辑</a>
      <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
    </script>
    <script>
      layui.use(['table','jquery'], function(){
        var table = layui.table;
        var $ = layui.jquery;

        table.on('tool(table)', function(obj){
          var data = obj.data;

          if(obj.event === 'edit'){
            layer.open({
                title:'新闻编辑',
                type: 2,
                maxmin: true,
                area: ['{:request()->isMobile()?'100%':'500px'}', '420px'],
                id:'editButton',
                content: '{:url('news/editNews')}?id='+data.id,
                end: function(){
                  location.href = location;
                }
            });
          }

          if(obj.event === 'del'){
            layer.confirm('风险提示：删除后不可恢复，确定删除？', function(index){
              $.post('{:url('news/deleteNews')}',{id:data.id},function(res){
                if(res.code==1){
                  obj.del();
                  layer.close(index);
                }else{
                  layer.msg(res.msg);
                  layer.close(index);
                }
              })
            });
          }

          if(obj.event === 'content'){
            layer.prompt({
              formType: 2
              ,title: '修改'
              ,value: data.content
            }, function(value, index){
              if(value==''){
                layer.msg('不能为空');
                return false;
              }
              $.post('{:url('news/editNews')}',{id:data.id,field_name:'content',field_value:value},function(res){
                if(res.code==1){
                  obj.update({content: value});
                  layer.close(index);
                }else{
                  layer.msg(res.msg);
                }
              });
            });
          }

        });
      });
    </script>


  </div>

</div>
{/block}
{block name="script"}
  <script>
    layui.use(['form', 'layedit', 'laydate'], function(){
      var form = layui.form
      ,layer = layui.layer
      ,laydate = layui.laydate;
      //日期
      laydate.render({
        elem: '#date'
      });
    });
  </script>
{/block}
